#ifndef __MARS_CORE_SINGLETON_H__
#define __MARS_CORE_SINGLETON_H__

namespace Core
{

template < typename T > class Singleton
{
public:
	static T&						Instance();
	static void						Destroy();

	bool							Initialize();
	void							Shutdown();

protected:
	explicit						Singleton();
									~Singleton();

protected:
	static T*						ms_pInstance;
};

template < typename T >
inline static T& Instance()
{
	if ( ms_pInstance == NULL )
	{
		ms_pInstance = new T();
	}

	return ms_pInstance;
}

template < typename T >
static inline void Destroy()
{
	SAFE_DELETE( ms_pInstance );
}

template < typename T >
inline Singleton< T >::Singleton()
{

}

template < typename T >
inline Singleton< T >::~Singleton()
{

}

template < typename T >
inline bool Singleton< T >::Initialize()
{
	return false;
}

template < typename T >
inline void Singleton< T >::Destroy()
{

}

} // end of namespace Core

#endif // #ifndef __MARS_CORE_SINGLETON_H__